<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加帮助中心</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="网站描述"/>
    <meta name="keywords" content=""/>
    <meta name="author" content="wangl"/>
    <link rel="icon" href="http://ow9lg82yy.bkt.clouddn.com/24f5c360-485d-4a6d-9468-2a61c353cf37.ico">
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/static/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <style type="text/css">
        .layui-form-item .layui-inline {
            width: 33.333%;
            float: left;
            margin-right: 0;
        }

        @media (max-width: 1240px) {
            .layui-form-item .layui-inline {
                width: 100%;
                float: none;
            }
        }

        .layui-form-item .role-box {
            position: relative;
        }

        .layui-form-item .role-box .jq-role-inline {
            height: 100%;
            overflow: auto;
        }

        /***
        *  ztree 图标变成黄色
        */
        .ztree .line {
            line-height: 0;
            border-top: none;
            float: none;
        }

        .ztree li span.button.ico_docu {
            background-position: -110px 0;
            margin-right: 2px;
            vertical-align: top;
        }

        .multiSelect {
            line-height: normal;
            height: auto;
            padding: 4px 10px;
            overflow: hidden;
            min-height: 38px;
            margin-top: -38px;
            left: 0;
            z-index: 99;
            position: relative;
            background: none;
        }

        .multiSelect a {
            padding: 2px 5px;
            background: #908e8e;
            border-radius: 2px;
            color: #fff;
            display: block;
            line-height: 20px;
            height: 20px;
            margin: 2px 5px 2px 0;
            float: left;
        }

        .multiSelect a span {
            float: left;
        }

        .multiSelect a i {
            float: left;
            display: block;
            margin: 2px 0 0 2px;
            border-radius: 2px;
            width: 8px;
            height: 8px;
            background: url(/static/images/close.png) no-repeat center;
            background-size: 65%;
            padding: 4px;
        }

        .multiSelect a i:hover {
            background-color: #545556;
        }

        .layui-field-box a {
            padding: 2px 5px;
            background: #908e8e;
            border-radius: 2px;
            color: #fff;
            display: block;
            line-height: 20px;
            height: 20px;
            margin: 2px 5px 22px 0;
            float: left;
        }

        .layui-field-box a span {
            float: left;
        }

        .boxadd {
            float: left;
            display: block;
            margin: 2px 0 0 2px;
            border-radius: 2px;
            width: 8px;
            height: 8px;
            background-size: 65%;
            padding: 4px;
        }
    </style>
</head>
<body class="childrenBody">
<#--action="/back/content/news/add"-->
<form class="layui-form" method="post"
      style="width:80%;">

    <div class="layui-form-item">
        <label class="layui-form-label">分类</label>
        <div class="layui-input-block">
            <select id="helperClass" name="helperClass">
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="helperTitle" name="helperTitle" placeholder="请输入标题">
        </div>
    </div>

    <div id="type0" class="layui-form-item">
        <input type="hidden" id="helperDetail" name="helperDetail">
        <div class="layui-form-item">
            <label class="layui-form-label">详情</label>
            <div class="layui-input-block">
                <textarea id="content" style="display: none;"></textarea>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="addBlogArticle" onclick="add()">立即提交</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script type="text/javascript" src="/static/js/wangEditor.min.js"></script>
<script type="text/javascript" src="/static/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<script>

    var layedit = null;
    var content = null;

    function add() {
        // alert($("#helperClass option:selected").text());
        // alert($("#helperClass option:selected").val());
        $.ajax({
                url: "/back/content/helper/add",
                type: "post",
                data: {
                    helperType: 0,
                    helperClassId: $("#helperClass option:selected").val(),
                    helperClass: $("#helperClass option:selected").text(),
                    helperTitle: $("#helperTitle").val(),
                    helperDetail: layedit.getContent(content)
                },
                success: function (data) {
                    // alert(data.data);
                    window.location.href = "/back/content/helper/listpage";
                }
            }
        );
    }

    layui.use(['element', 'layedit', 'form'], function () {
        var form = layui.form;
        layedit = layui.layedit;
        layedit.set({
            uploadImage: {
                url: '/back/content/an/content/picture/upload',
                type: 'post'
            }
        });

        function loadSelect() {
            $.ajax({
                    url: "/back/content/helperclass/list",
                    type: "post",
                    data: {},
                    success: function (data) {
                        var list = data.data.list;
                        for (var i = 0; i < list.length; i++) {
                            $("#helperClass").append("<option value='" + list[i].id + "'>" + list[i].helperClass + "</option>");
                        }
                        form.render("select");
                    }
                }
            );
        }

        loadSelect();
        content = layedit.build('content'); //建立编辑器
    });
</script>
</body>
</html>